package com.jni.parsers;

import java.util.ArrayList;

import android.util.Log;


import com.google.gson.Gson;
import com.jni.model.Article;
import com.jni.model.Lnews;
import com.jni.ws.WsResonseLastNews;

public class LastNewsParser {
	Gson gson = new Gson();
	public WsResonseLastNews wsRespLNews;
	
	public LastNewsParser(String resultat) {
		wsRespLNews = gson.fromJson(resultat, WsResonseLastNews.class);
		
	}
	
	public boolean parse(){
		if(wsRespLNews != null){
			Log.i("parse sucess", "LastNewsParser");
			return true;
		}
		else {
			Log.i("parse failed", "LastNewsParser");
			return false;
		}
			
	}
	
	public ArrayList<Article> getObjects() {
		// TODO Auto-generated method stub
		ArrayList<Article> articles = new ArrayList<Article>();
		for (Lnews lnews : wsRespLNews.Lnews) {
//			Log.i("Dj Name", "" + auteur.dj.name);
			articles.add(lnews.article);
		}
		return articles;
	}
}
